<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
  <div id="app">
    count:{{ count }}
    <!-- 创建一个 todo-item 组件实例 -->
    <ol>
      <todo-item
      v-for="item in groceryList"
      :todo="item"
      :key="item.id"
      />
    </ol>
  </div>

  <script>
    // 创建 Vue 应用
    const app = Vue.createApp({
      setup() {
        const count = Vue.ref(0)
        const groceryList = Vue.reactive([
          { id: 0, text: 'Vegetables' },
          { id: 1, text: 'Cheese' },
          { id: 2, text: 'Whatever else humans are supposed to eat' }
        ])
        return {
          count,
          groceryList
        }
      }
    })

    // 定义名为 todo-item 的组件
    app.component('todo-item', {
      props: {
        todo: String
      },
      template: `<li>{{ todo.text }}</li>`
    })

    // 挂载 Vue 应用
    app.mount('#app')
  </script>
</body>
</html>